/**
 * related to memberListCell.ui
 * 
 * @Author : chenglm
 * @Timestamp : 2016-09-27
 */
var app = sm("do_App");
var page = sm("do_Page");
var root=ui("$");
var aLayout_base = ui("aLayout_base");
var aLayout_img = ui("aLayout_img");
var imageView_photosImg = ui("imageView_photosImg");
var gridView_starList = ui("gridView_starList");
var label_realName = ui("label_realName");
var label_birthPlace = ui("label_birthPlace");
var label_typeStr = ui("label_typeStr");
var do_Button_1 = ui("do_Button_1");
var do_Button_2 = ui("do_Button_2");
var label_remark = ui("label_remark");
var helperOpen = require("helper/open");

//设置数据绑定的映射关系
root.setMapping({
	"aLayout_base.tag":"id",
	"aLayout_img.tag":"fileDomain",
	"imageView_photosImg.tag":"photosImg",
	"label_realName.text":"realName",
	"label_distanceStr.text":"distanceStr",
	"label_orderedCount.text":"orderedCount",
	"label_typeStr.text":"typeStr",
	"label_name.text":"name",
	"gridView_starList.tag":"feedbackScore",
	"label_birthPlace.text":"birthPlace",
	"label_remark.text":"remark"
});

root.on("dataRefreshed", function(){
	if(imageView_photosImg.tag){
		imageView_photosImg.source= aLayout_img.tag + "" + imageView_photosImg.tag;
	}
	var listdata4Star = mm("do_ListData");
	gridView_starList.bindItems(listdata4Star);
	var feedbackScore = gridView_starList.tag;
	var starListNew = [];
	for(var m=1;m<=5;m++){
		if(m <= feedbackScore){
			starListNew.push({"starImg":"source://image/common/x_01.png"});
		}else{
			starListNew.push({"starImg":"source://image/common/x_02.png"});
		}
	}
	listdata4Star.addData(starListNew);
	gridView_starList.refreshItems();
});

do_Button_1.on("touch", function(data){
	var id = aLayout_base.tag;
	var name = label_realName.text + " " + label_typeStr.text;
	var param = {"productId":id,"name":name};
	helperOpen.open("source://view/homemaking/comment/list.ui",param);
});

do_Button_2.on("touch", function(data){
	var fileDomain = aLayout_img.tag;
	var photosImg = imageView_photosImg.tag;
	var realName = label_realName.text;
	var birthPlace = label_birthPlace.text;
	var id = aLayout_base.tag;
	var remark = label_remark.text;
	var one = {"id":id,"fileDomain":fileDomain,"photosImg":photosImg,"realName":realName,"birthPlace":birthPlace,"remark":remark,"fromPage":"memberList"};
	app.closePage(one);
});